
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 03/27/2013 09:16:05
-- Generated from EDMX file: C:\DATA\BulaUmzüge\Umzugsfirma\Umzugsfirma\DataModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Umzugsfirma];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_CustomerContactDetails]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CustomerSet] DROP CONSTRAINT [FK_CustomerContactDetails];
GO
IF OBJECT_ID(N'[dbo].[FK_EmployeeContactDetails]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EmployeeSet] DROP CONSTRAINT [FK_EmployeeContactDetails];
GO
IF OBJECT_ID(N'[dbo].[FK_InvoiceAddressContactDetails]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[InvoiceAddressSet] DROP CONSTRAINT [FK_InvoiceAddressContactDetails];
GO
IF OBJECT_ID(N'[dbo].[FK_DischargePlaceOpportunity_DischargePlace]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DischargePlaceOpportunity] DROP CONSTRAINT [FK_DischargePlaceOpportunity_DischargePlace];
GO
IF OBJECT_ID(N'[dbo].[FK_DischargePlaceOpportunity_Opportunity]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DischargePlaceOpportunity] DROP CONSTRAINT [FK_DischargePlaceOpportunity_Opportunity];
GO
IF OBJECT_ID(N'[dbo].[FK_OpportunityCustomer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OpportunitySet] DROP CONSTRAINT [FK_OpportunityCustomer];
GO
IF OBJECT_ID(N'[dbo].[FK_VehicleOpportunity_Vehicle]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[VehicleOpportunity] DROP CONSTRAINT [FK_VehicleOpportunity_Vehicle];
GO
IF OBJECT_ID(N'[dbo].[FK_VehicleOpportunity_Opportunity]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[VehicleOpportunity] DROP CONSTRAINT [FK_VehicleOpportunity_Opportunity];
GO
IF OBJECT_ID(N'[dbo].[FK_DeliveryNoteInvoice]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DeliveryNoteSet] DROP CONSTRAINT [FK_DeliveryNoteInvoice];
GO
IF OBJECT_ID(N'[dbo].[FK_OrderConfirmationReceipt]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OrderConfirmationSet] DROP CONSTRAINT [FK_OrderConfirmationReceipt];
GO
IF OBJECT_ID(N'[dbo].[FK_OrderConfirmationInvoice]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OrderConfirmationSet] DROP CONSTRAINT [FK_OrderConfirmationInvoice];
GO
IF OBJECT_ID(N'[dbo].[FK_OfferOrderConfirmation]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OrderConfirmationSet] DROP CONSTRAINT [FK_OfferOrderConfirmation];
GO
IF OBJECT_ID(N'[dbo].[FK_OpportunityOffer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OfferSet] DROP CONSTRAINT [FK_OpportunityOffer];
GO
IF OBJECT_ID(N'[dbo].[FK_OpportunityInvoiceAddress]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OpportunitySet] DROP CONSTRAINT [FK_OpportunityInvoiceAddress];
GO
IF OBJECT_ID(N'[dbo].[FK_OfferEmployee]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OfferSet] DROP CONSTRAINT [FK_OfferEmployee];
GO
IF OBJECT_ID(N'[dbo].[FK_OpportunityEmployee]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OpportunitySet] DROP CONSTRAINT [FK_OpportunityEmployee];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[ContactDetailsSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ContactDetailsSet];
GO
IF OBJECT_ID(N'[dbo].[DischargePlaceSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DischargePlaceSet];
GO
IF OBJECT_ID(N'[dbo].[VehicleSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VehicleSet];
GO
IF OBJECT_ID(N'[dbo].[EmployeeSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EmployeeSet];
GO
IF OBJECT_ID(N'[dbo].[OpportunitySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OpportunitySet];
GO
IF OBJECT_ID(N'[dbo].[OfferSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OfferSet];
GO
IF OBJECT_ID(N'[dbo].[OrderConfirmationSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OrderConfirmationSet];
GO
IF OBJECT_ID(N'[dbo].[InvoiceSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[InvoiceSet];
GO
IF OBJECT_ID(N'[dbo].[ReceiptSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ReceiptSet];
GO
IF OBJECT_ID(N'[dbo].[DeliveryNoteSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeliveryNoteSet];
GO
IF OBJECT_ID(N'[dbo].[CustomerSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CustomerSet];
GO
IF OBJECT_ID(N'[dbo].[InvoiceAddressSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[InvoiceAddressSet];
GO
IF OBJECT_ID(N'[dbo].[DischargePlaceOpportunity]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DischargePlaceOpportunity];
GO
IF OBJECT_ID(N'[dbo].[VehicleOpportunity]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VehicleOpportunity];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'ContactDetailsSet'
CREATE TABLE [dbo].[ContactDetailsSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Forname] nvarchar(max)  NOT NULL,
    [Surname] nvarchar(max)  NOT NULL,
    [CompanyName] nvarchar(max)  NOT NULL,
    [IsCompany] bit  NOT NULL,
    [Street1Address] nvarchar(max)  NOT NULL,
    [Street2Address] nvarchar(max)  NOT NULL,
    [ZipCode] smallint  NOT NULL,
    [City] nvarchar(max)  NOT NULL,
    [HomePhoneNumber] nvarchar(max)  NOT NULL,
    [MobilePhoneNumber] nvarchar(max)  NOT NULL,
    [BusinessPhoneNumber] nvarchar(max)  NOT NULL,
    [EmailAddress] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'DischargePlaceSet'
CREATE TABLE [dbo].[DischargePlaceSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Street1Address] nvarchar(max)  NOT NULL,
    [Street2Address] nvarchar(max)  NOT NULL,
    [ZipCode] smallint  NOT NULL,
    [City] nvarchar(max)  NOT NULL,
    [ContactPhone] smallint  NOT NULL
);
GO

-- Creating table 'VehicleSet'
CREATE TABLE [dbo].[VehicleSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Make] nvarchar(max)  NOT NULL,
    [Model] nvarchar(max)  NOT NULL,
    [Volume] smallint  NOT NULL,
    [DailyRate] smallint  NOT NULL
);
GO

-- Creating table 'EmployeeSet'
CREATE TABLE [dbo].[EmployeeSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [ContactDetails_Id] int  NOT NULL
);
GO

-- Creating table 'OpportunitySet'
CREATE TABLE [dbo].[OpportunitySet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CreationDate] datetime  NOT NULL,
    [Customer_Id] int  NOT NULL,
    [InvoiceAddress_Id] int  NOT NULL,
    [Employee_Id] int  NOT NULL
);
GO

-- Creating table 'OfferSet'
CREATE TABLE [dbo].[OfferSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CreationDate] datetime  NOT NULL,
    [PrintDate] datetime  NOT NULL,
    [EmailSendDate] datetime  NOT NULL,
    [IsAcknowledged] bit  NOT NULL,
    [AcknowledgedDate] datetime  NOT NULL,
    [Opportunity_Id] int  NOT NULL,
    [Employee_Id] int  NOT NULL
);
GO

-- Creating table 'OrderConfirmationSet'
CREATE TABLE [dbo].[OrderConfirmationSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PrintDate] datetime  NOT NULL,
    [EmailSendDate] datetime  NOT NULL,
    [Receipt_Id] int  NOT NULL,
    [Invoice_Id] int  NOT NULL,
    [Offer_Id] int  NOT NULL
);
GO

-- Creating table 'InvoiceSet'
CREATE TABLE [dbo].[InvoiceSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CreationDate] datetime  NOT NULL,
    [InvoiceDate] datetime  NOT NULL,
    [EmailSendDate] datetime  NOT NULL,
    [PrintDate] datetime  NOT NULL
);
GO

-- Creating table 'ReceiptSet'
CREATE TABLE [dbo].[ReceiptSet] (
    [Id] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'DeliveryNoteSet'
CREATE TABLE [dbo].[DeliveryNoteSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CreationDate] datetime  NOT NULL,
    [DeliveryNoteDate] datetime  NOT NULL,
    [EmailSendDate] datetime  NOT NULL,
    [PrintDate] datetime  NOT NULL,
    [Invoice_Id] int  NOT NULL
);
GO

-- Creating table 'CustomerSet'
CREATE TABLE [dbo].[CustomerSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [ContactDetails_Id] int  NOT NULL
);
GO

-- Creating table 'InvoiceAddressSet'
CREATE TABLE [dbo].[InvoiceAddressSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [ContactDetails_Id] int  NOT NULL
);
GO

-- Creating table 'TitlesSet'
CREATE TABLE [dbo].[TitlesSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [TextDE] nvarchar(max)  NOT NULL,
    [TextFR] nvarchar(max)  NOT NULL,
    [TextEN] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'DischargePlaceOpportunity'
CREATE TABLE [dbo].[DischargePlaceOpportunity] (
    [DischargePlace_Id] int  NOT NULL,
    [Opportunity_Id] int  NOT NULL
);
GO

-- Creating table 'VehicleOpportunity'
CREATE TABLE [dbo].[VehicleOpportunity] (
    [Vehicle_Id] int  NOT NULL,
    [Opportunity_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'ContactDetailsSet'
ALTER TABLE [dbo].[ContactDetailsSet]
ADD CONSTRAINT [PK_ContactDetailsSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DischargePlaceSet'
ALTER TABLE [dbo].[DischargePlaceSet]
ADD CONSTRAINT [PK_DischargePlaceSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'VehicleSet'
ALTER TABLE [dbo].[VehicleSet]
ADD CONSTRAINT [PK_VehicleSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EmployeeSet'
ALTER TABLE [dbo].[EmployeeSet]
ADD CONSTRAINT [PK_EmployeeSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OpportunitySet'
ALTER TABLE [dbo].[OpportunitySet]
ADD CONSTRAINT [PK_OpportunitySet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OfferSet'
ALTER TABLE [dbo].[OfferSet]
ADD CONSTRAINT [PK_OfferSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OrderConfirmationSet'
ALTER TABLE [dbo].[OrderConfirmationSet]
ADD CONSTRAINT [PK_OrderConfirmationSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'InvoiceSet'
ALTER TABLE [dbo].[InvoiceSet]
ADD CONSTRAINT [PK_InvoiceSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ReceiptSet'
ALTER TABLE [dbo].[ReceiptSet]
ADD CONSTRAINT [PK_ReceiptSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DeliveryNoteSet'
ALTER TABLE [dbo].[DeliveryNoteSet]
ADD CONSTRAINT [PK_DeliveryNoteSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'CustomerSet'
ALTER TABLE [dbo].[CustomerSet]
ADD CONSTRAINT [PK_CustomerSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'InvoiceAddressSet'
ALTER TABLE [dbo].[InvoiceAddressSet]
ADD CONSTRAINT [PK_InvoiceAddressSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'TitlesSet'
ALTER TABLE [dbo].[TitlesSet]
ADD CONSTRAINT [PK_TitlesSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [DischargePlace_Id], [Opportunity_Id] in table 'DischargePlaceOpportunity'
ALTER TABLE [dbo].[DischargePlaceOpportunity]
ADD CONSTRAINT [PK_DischargePlaceOpportunity]
    PRIMARY KEY NONCLUSTERED ([DischargePlace_Id], [Opportunity_Id] ASC);
GO

-- Creating primary key on [Vehicle_Id], [Opportunity_Id] in table 'VehicleOpportunity'
ALTER TABLE [dbo].[VehicleOpportunity]
ADD CONSTRAINT [PK_VehicleOpportunity]
    PRIMARY KEY NONCLUSTERED ([Vehicle_Id], [Opportunity_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [ContactDetails_Id] in table 'CustomerSet'
ALTER TABLE [dbo].[CustomerSet]
ADD CONSTRAINT [FK_CustomerContactDetails]
    FOREIGN KEY ([ContactDetails_Id])
    REFERENCES [dbo].[ContactDetailsSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CustomerContactDetails'
CREATE INDEX [IX_FK_CustomerContactDetails]
ON [dbo].[CustomerSet]
    ([ContactDetails_Id]);
GO

-- Creating foreign key on [ContactDetails_Id] in table 'EmployeeSet'
ALTER TABLE [dbo].[EmployeeSet]
ADD CONSTRAINT [FK_EmployeeContactDetails]
    FOREIGN KEY ([ContactDetails_Id])
    REFERENCES [dbo].[ContactDetailsSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EmployeeContactDetails'
CREATE INDEX [IX_FK_EmployeeContactDetails]
ON [dbo].[EmployeeSet]
    ([ContactDetails_Id]);
GO

-- Creating foreign key on [ContactDetails_Id] in table 'InvoiceAddressSet'
ALTER TABLE [dbo].[InvoiceAddressSet]
ADD CONSTRAINT [FK_InvoiceAddressContactDetails]
    FOREIGN KEY ([ContactDetails_Id])
    REFERENCES [dbo].[ContactDetailsSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_InvoiceAddressContactDetails'
CREATE INDEX [IX_FK_InvoiceAddressContactDetails]
ON [dbo].[InvoiceAddressSet]
    ([ContactDetails_Id]);
GO

-- Creating foreign key on [DischargePlace_Id] in table 'DischargePlaceOpportunity'
ALTER TABLE [dbo].[DischargePlaceOpportunity]
ADD CONSTRAINT [FK_DischargePlaceOpportunity_DischargePlace]
    FOREIGN KEY ([DischargePlace_Id])
    REFERENCES [dbo].[DischargePlaceSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Opportunity_Id] in table 'DischargePlaceOpportunity'
ALTER TABLE [dbo].[DischargePlaceOpportunity]
ADD CONSTRAINT [FK_DischargePlaceOpportunity_Opportunity]
    FOREIGN KEY ([Opportunity_Id])
    REFERENCES [dbo].[OpportunitySet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DischargePlaceOpportunity_Opportunity'
CREATE INDEX [IX_FK_DischargePlaceOpportunity_Opportunity]
ON [dbo].[DischargePlaceOpportunity]
    ([Opportunity_Id]);
GO

-- Creating foreign key on [Customer_Id] in table 'OpportunitySet'
ALTER TABLE [dbo].[OpportunitySet]
ADD CONSTRAINT [FK_OpportunityCustomer]
    FOREIGN KEY ([Customer_Id])
    REFERENCES [dbo].[CustomerSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OpportunityCustomer'
CREATE INDEX [IX_FK_OpportunityCustomer]
ON [dbo].[OpportunitySet]
    ([Customer_Id]);
GO

-- Creating foreign key on [Vehicle_Id] in table 'VehicleOpportunity'
ALTER TABLE [dbo].[VehicleOpportunity]
ADD CONSTRAINT [FK_VehicleOpportunity_Vehicle]
    FOREIGN KEY ([Vehicle_Id])
    REFERENCES [dbo].[VehicleSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Opportunity_Id] in table 'VehicleOpportunity'
ALTER TABLE [dbo].[VehicleOpportunity]
ADD CONSTRAINT [FK_VehicleOpportunity_Opportunity]
    FOREIGN KEY ([Opportunity_Id])
    REFERENCES [dbo].[OpportunitySet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_VehicleOpportunity_Opportunity'
CREATE INDEX [IX_FK_VehicleOpportunity_Opportunity]
ON [dbo].[VehicleOpportunity]
    ([Opportunity_Id]);
GO

-- Creating foreign key on [Invoice_Id] in table 'DeliveryNoteSet'
ALTER TABLE [dbo].[DeliveryNoteSet]
ADD CONSTRAINT [FK_DeliveryNoteInvoice]
    FOREIGN KEY ([Invoice_Id])
    REFERENCES [dbo].[InvoiceSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DeliveryNoteInvoice'
CREATE INDEX [IX_FK_DeliveryNoteInvoice]
ON [dbo].[DeliveryNoteSet]
    ([Invoice_Id]);
GO

-- Creating foreign key on [Receipt_Id] in table 'OrderConfirmationSet'
ALTER TABLE [dbo].[OrderConfirmationSet]
ADD CONSTRAINT [FK_OrderConfirmationReceipt]
    FOREIGN KEY ([Receipt_Id])
    REFERENCES [dbo].[ReceiptSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrderConfirmationReceipt'
CREATE INDEX [IX_FK_OrderConfirmationReceipt]
ON [dbo].[OrderConfirmationSet]
    ([Receipt_Id]);
GO

-- Creating foreign key on [Invoice_Id] in table 'OrderConfirmationSet'
ALTER TABLE [dbo].[OrderConfirmationSet]
ADD CONSTRAINT [FK_OrderConfirmationInvoice]
    FOREIGN KEY ([Invoice_Id])
    REFERENCES [dbo].[InvoiceSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrderConfirmationInvoice'
CREATE INDEX [IX_FK_OrderConfirmationInvoice]
ON [dbo].[OrderConfirmationSet]
    ([Invoice_Id]);
GO

-- Creating foreign key on [Offer_Id] in table 'OrderConfirmationSet'
ALTER TABLE [dbo].[OrderConfirmationSet]
ADD CONSTRAINT [FK_OfferOrderConfirmation]
    FOREIGN KEY ([Offer_Id])
    REFERENCES [dbo].[OfferSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OfferOrderConfirmation'
CREATE INDEX [IX_FK_OfferOrderConfirmation]
ON [dbo].[OrderConfirmationSet]
    ([Offer_Id]);
GO

-- Creating foreign key on [Opportunity_Id] in table 'OfferSet'
ALTER TABLE [dbo].[OfferSet]
ADD CONSTRAINT [FK_OpportunityOffer]
    FOREIGN KEY ([Opportunity_Id])
    REFERENCES [dbo].[OpportunitySet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OpportunityOffer'
CREATE INDEX [IX_FK_OpportunityOffer]
ON [dbo].[OfferSet]
    ([Opportunity_Id]);
GO

-- Creating foreign key on [InvoiceAddress_Id] in table 'OpportunitySet'
ALTER TABLE [dbo].[OpportunitySet]
ADD CONSTRAINT [FK_OpportunityInvoiceAddress]
    FOREIGN KEY ([InvoiceAddress_Id])
    REFERENCES [dbo].[InvoiceAddressSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OpportunityInvoiceAddress'
CREATE INDEX [IX_FK_OpportunityInvoiceAddress]
ON [dbo].[OpportunitySet]
    ([InvoiceAddress_Id]);
GO

-- Creating foreign key on [Employee_Id] in table 'OfferSet'
ALTER TABLE [dbo].[OfferSet]
ADD CONSTRAINT [FK_OfferEmployee]
    FOREIGN KEY ([Employee_Id])
    REFERENCES [dbo].[EmployeeSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OfferEmployee'
CREATE INDEX [IX_FK_OfferEmployee]
ON [dbo].[OfferSet]
    ([Employee_Id]);
GO

-- Creating foreign key on [Employee_Id] in table 'OpportunitySet'
ALTER TABLE [dbo].[OpportunitySet]
ADD CONSTRAINT [FK_OpportunityEmployee]
    FOREIGN KEY ([Employee_Id])
    REFERENCES [dbo].[EmployeeSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OpportunityEmployee'
CREATE INDEX [IX_FK_OpportunityEmployee]
ON [dbo].[OpportunitySet]
    ([Employee_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------